package com.igeekhome.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.igeekhome.biz.IAttendanceStatisticsService;
import com.igeekhome.biz.IWorkQualityStatisticsService;
import com.igeekhome.biz.IWorkloadStatisticsService;
import com.igeekhome.pojo.AttendanceStatistics;
import com.igeekhome.pojo.WorkQualityStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 * 工作质量统计 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-03-16
 */
@Controller
@RequestMapping("/workQualityStatistics")
public class WorkQualityStatisticsController {

    @Autowired//注入
    private IWorkQualityStatisticsService iWorkQualityStatisticsService;

   //工作质量表的统计
    @RequestMapping("/workquality")
    public String workquality(HttpSession session, Model model, @RequestParam("value")String value, @RequestParam("current")Integer current, @RequestParam("size")Integer size){
        IPage<WorkQualityStatistics> page =new Page<>(current,size);

        QueryWrapper<WorkQualityStatistics> qw=new QueryWrapper<>();
         qw.like("nickname",value).or().like("effectivesessioncount", value).or().like("resolved", value).or().like("unsolved", value).or().like("goodreview",value).or().like("mediumreview",value).or().like("badreview",value).or().like("noreview",value).or().like("id",value);

        IPage<WorkQualityStatistics> page1=iWorkQualityStatisticsService.page(page,qw);
        List<WorkQualityStatistics> list = page1.getRecords();

        session.setAttribute("workqualityCount",this.iWorkQualityStatisticsService.count());

        long pagesCount=page1.getPages();
        model.addAttribute("list",list);
        model.addAttribute("pagesCount",pagesCount);

        return "/workqualitybiao";

    }

    //首页
    @RequestMapping("/shouye")
    public String shouye(){
        return "index";
    }



//    @RequestMapping("/search")
//    public String search(Model model, String value){
//        QueryWrapper<WorkQualityStatistics> qw=new QueryWrapper<>();
////        qw.like("realname",value);
//        qw.like("nickname",value).or().like("effectivesessioncount", value).or().like("resolved", value).or().like("unsolved", value).or().like("goodreview",value).or().like("mediumreview",value).or().like("badreview",value).or().like("noreview",value).or().like("id",value);
//        List<WorkQualityStatistics> list=iWorkQualityStatisticsService.list(qw);
//        model.addAttribute("list",list);
//
//        return "workqualitybiao";
//    }
}

